#include <iostream>
#include<vector>
#include<math.h>
using namespace std;

int check(int num)
{
    if (num < 10) return 0;
    vector<int> v;
    while (num)
    {
        v.push_back(num % 10);
        num /= 10;
    }
    for (int i = 0;i <= v.size() - 2;i++)
    {
        for (int j = i + 1;j <= v.size() - 1;j++)
        {
            if (v[i] != 0)
            {
                int flag = 1;
                int tmp = v[i] * 10 + v[j];
                for (int k = 2;k <= sqrt(tmp);k++)
                {
                    if (tmp % k == 0)
                    {
                        flag = 0;
                    }
                }
                if (flag == 1)
                {
                    return 1;
                }


            }
            if (v[j] != 0)
            {
                int flag = 1;
                int tmp = v[j] * 10 + v[i];
                for (int k = 2;k <= sqrt(tmp);k++)
                {
                    if (tmp % k == 0)
                    {
                        flag = 0;
                    }
                }
                if (flag == 1)
                {
                    return 1;
                }


            }
        }

    }
    return 0;
}
int main() {
    int a, b;
    cin >> a >> b;
    int ret = 0;
    for (int i = a;i <= b;i++)
    {
        ret += check(i);
    }
    cout << ret;
    return 0;
}